﻿using ChurchDiary.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChurchDiary.Tool
{
    public partial class frmGenerateInsertProcedure : frmBase
    {
        public frmGenerateInsertProcedure()
        {
            InitializeComponent();
        }
        private void frmGenerateInsertProcedure_Load(object sender, EventArgs e)
        {
            BindAllTables();
        }
        public void BindAllTables()
        {
            DataTable dt = new BLL_Tools().GetAllTables();
            cboTableNames.DataSource = resort(dt, "TABLE_NAME", "DESC");
            cboTableNames.DisplayMember = "TABLE_NAME";
            cboTableNames.ValueMember = "TABLE_NAME";
        }
        public static DataTable resort(DataTable dt, string colName, string direction)
        {
            DataTable dtOut = null;
            dt.DefaultView.Sort = colName + " " + direction;
            dtOut = dt.DefaultView.ToTable();
            return dtOut;
        }
        public void InitializeListView()
        {
            lstvColumns.Columns.Add("tABLE");
        }
        private void cboTableNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstvColumns.Items.Clear();
            lstvColumns.MultiSelect = true;
            DataTable dt = new BLL_Tools().GetTableInfo(cboTableNames.SelectedValue.ToString(), "GetTableInfo");
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                lstvColumns.Items.Add(new ListViewItem(new string[] { dt.Rows[i]["TABLE_NAME"].ToString(), dt.Rows[i]["COLUMN_NAME"].ToString(), dt.Rows[i]["DATA_TYPE"].ToString(), dt.Rows[i]["CHARACTER_MAXIMUM_LENGTH"].ToString(), dt.Rows[i]["IS_NULLABLE"].ToString() }));
            }
        }
        private void btnAddSelected_Click(object sender, EventArgs e)
        {
            if (lstvColumns.SelectedItems.Count > 0)
            {
                for (int i = 0; i <= lstvColumns.SelectedItems.Count-1; i++)
                {
                    ListViewItem item = lstvColumns.SelectedItems[i];
                    lstMainList.Items.Add(new ListViewItem(new string[] { item.SubItems[0].Text, item.SubItems[1].Text, item.SubItems[2].Text, item.SubItems[3].Text, item.SubItems[4].Text }));
                }
            }
            else
            {
                MessageBox.Show("Select Item not found");
            }
        }
        private void btnall_Click(object sender, EventArgs e)
        {
            DataTable dt = new BLL_Tools().GetTableInfo(cboTableNames.SelectedValue.ToString(), "GetTableInfo");
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                lstMainList.Items.Add(new ListViewItem(new string[] { dt.Rows[i]["TABLE_NAME"].ToString(), dt.Rows[i]["COLUMN_NAME"].ToString(), dt.Rows[i]["DATA_TYPE"].ToString(), dt.Rows[i]["CHARACTER_MAXIMUM_LENGTH"].ToString(), dt.Rows[i]["IS_NULLABLE"].ToString() }));
            }
        }

        private void btnGenerate_Click(object sender, EventArgs e)
        {
            rchResult.Text = "";
            StringBuilder sbProcedure = new StringBuilder();
            if(txtEntityName.Text.Trim()!="")
            {
                ///produre Generation
                string procedureName = "[dbo].[IDU_" + txtEntityName.Text.Replace("Entity", "").ToString() + "]";
                sbProcedure.Append("CREATE PROC "+ procedureName + " \n");
                sbProcedure.Append("\t@Mode\t\t\t\t\tVARCHAR(24),\n");
                for (int i = 0; i <= lstMainList.Items.Count - 1; i++)
                {
                    ListViewItem item = lstvColumns.Items[i];
                    if (item.SubItems[1].Text.ToUpper() == "CREATEDBY" || item.SubItems[1].Text.ToUpper() == "UPDATEDBY" || item.SubItems[1].Text.ToUpper() == "CREATEDON" || item.SubItems[1].Text.ToUpper() == "UPDATEDON" || item.SubItems[1].Text.ToUpper() == "STATUS")
                    {
                        continue;
                    }
                    sbProcedure.Append("\t@" + item.SubItems[1].Text);
                    sbProcedure.Append("\t\t\t\t\t"+item.SubItems[2].Text.ToUpper());
                    if(!string.IsNullOrEmpty( item.SubItems[3].Text.ToUpper()))
                    {
                        if (item.SubItems[3].Text.ToUpper() != "-1")
                        {
                            sbProcedure.Append("(" + item.SubItems[3].Text.ToUpper() + ")");
                        }
                        else if(item.SubItems[3].Text.ToUpper() == "-1")
                        {
                            sbProcedure.Append("(MAX)");
                        }
                    }
                    switch (item.SubItems[2].Text.ToUpper())
                    {
                        case "UNIQUEIDENTIFIER":
                            sbProcedure.Append(GetIsNullCondition(item.SubItems[4].Text));
                            break;
                        case "INT":
                            sbProcedure.Append("=0,\n");
                            break;
                        case "NVARCHAR":
                            sbProcedure.Append(GetIsNullCondition(item.SubItems[4].Text));
                            break;
                        case "DATETIME":
                            sbProcedure.Append(GetIsNullCondition(item.SubItems[4].Text));
                            break;
                        case "BIT":
                            sbProcedure.Append("=0,\n");
                            break;
                        default:
                            break;
                    }
                }
                string strSectionOne = sbProcedure.ToString();
                var index = strSectionOne.ToString().LastIndexOf(',');
                strSectionOne = strSectionOne.Substring(0, index);
                StringBuilder sbNewSection = new StringBuilder(strSectionOne);
                sbNewSection.Append("\nAS\n");
                sbNewSection.Append("BEGIN\n");
                sbNewSection.Append("\tBEGIN TRANSACTION\n");
                sbNewSection.Append("\tDECLARE @Error AS INT=0\n");
                sbNewSection.Append("\tIF(@Mode='INS')\n");
                sbNewSection.Append("\tBEGIN\n");
                sbNewSection.Append("\t\t------your insert loginic here-----\n");
                sbNewSection.Append("\tEND\n");
                sbNewSection.Append("\tELSE IF(@Mode='UPD')\n");
                sbNewSection.Append("\tBEGIN\n");
                sbNewSection.Append("\t\t------your insert loginic here-----\n");
                sbNewSection.Append("\tEND\n");
                sbNewSection.Append("\tELSE IF(@Mode='DEL')\n");
                sbNewSection.Append("\tBEGIN\n");
                sbNewSection.Append("\t\t------your insert loginic here-----\n");
                sbNewSection.Append("\tEND\n");
                sbNewSection.Append("\tCOMMIT TRANSACTION\n");
                sbNewSection.Append("\tAEXISTS:\n");
                sbNewSection.Append("\t\tSELECT 'EIX'\n");
                sbNewSection.Append("\t\tROLLBACK TRANSACTION\n");
                sbNewSection.Append("\t\tGOTO FINAL\n");
                sbNewSection.Append("\tISUCCESS:\n");
                sbNewSection.Append("\t\tSELECT 'ISUS'\n");
                sbNewSection.Append("\t\tCOMMIT TRANSACTION\n");
                sbNewSection.Append("\t\tGOTO FINAL\n");
                sbNewSection.Append("\tUSUCCESS:\n");
                sbNewSection.Append("\t\tSELECT 'USUS'\n");
                sbNewSection.Append("\t\tCOMMIT TRANSACTION\n");
                sbNewSection.Append("\t\tGOTO FINAL\n");
                sbNewSection.Append("\tDSUCCESS:\n");
                sbNewSection.Append("\t\tSELECT 'DSUS'\n");
                sbNewSection.Append("\t\tCOMMIT TRANSACTION\n");
                sbNewSection.Append("\t\tGOTO FINAL\n");
                sbNewSection.Append("\tERROR:\n");
                sbNewSection.Append("\t\tSELECT 'ERR'\n");
                sbNewSection.Append("\t\tROLLBACK TRANSACTION\n");
                sbNewSection.Append("\t\tGOTO FINAL\n");
                sbNewSection.Append("\tFINAL:\n");
                sbNewSection.Append("END\n");
                ///produre Generation end
                
                
                if (!chkGenerate.Checked || txtEntityName.Text!="")
                {
                    ///Interface Generation start
                    sbNewSection.Append("\n\n\n");
                    sbNewSection.Append("---------------Interfacefunctions start--------------\n");
                    sbNewSection.Append("string Insert" + txtEntityName.Text.Replace("Entity", "") + "("+ txtEntityName.Text +" "+ txtEntityName.Text.Replace("Entity","") +");\n");
                    sbNewSection.Append("string Update" + txtEntityName.Text.Replace("Entity", "") + "(" + txtEntityName.Text + " " + txtEntityName.Text.Replace("Entity", "") + ");\n");
                    sbNewSection.Append("string Delete" + txtEntityName.Text.Replace("Entity", "") + "(" + txtEntityName.Text + " " + txtEntityName.Text.Replace("Entity", "") + "Id);\n");
                    sbNewSection.Append("List<"+ txtEntityName.Text +"> Get" + txtEntityName.Text.Replace("Entity", "").ToLowerInvariant() + " (int PageNo, string SearchKey, string Sort, string SortMode, int PerPage);\n");
                    sbNewSection.Append(txtEntityName.Text + " Get" + txtEntityName.Text.Replace("Entity", "") + "(Guid " + txtEntityName.Text.Replace("Entity", "") + "Id);\n");
                    sbNewSection.Append("---------------Interfacefunctions End--------------\n");
                    sbNewSection.Append("\n\n\n");
                    ///Interface Generation End


                    ///DataAccess Generation Start
                    sbNewSection.Append("\n\n\n");
                    sbNewSection.Append("---------------DataAccess start--------------\n");
                    //Insert
                    sbNewSection.Append("public string Insert" + txtEntityName.Text.Replace("Entity", "")  + "(" + txtEntityName.Text + " " + txtEntityName.Text.Replace("Entity", "") + ")\n");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"string IResult = ""SME"";");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"try");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t");
                    string DbComment = "using (DbCommand dbCommand = SQLServer.GetStoredProcCommand(\"" + procedureName + "\"))";
                    sbNewSection.Append(DbComment);
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@Mode"", DbType.String, eMode.INS);");
                    sbNewSection.Append("\n");
                    for (int i = 0; i <= lstMainList.Items.Count - 1; i++)
                    {
                        ListViewItem item = lstvColumns.Items[i];
                        if (item.SubItems[1].Text.ToUpper() == "CREATEDBY" || item.SubItems[1].Text.ToUpper() == "UPDATEDBY" || item.SubItems[1].Text.ToUpper() == "CREATEDON" || item.SubItems[1].Text.ToUpper() == "UPDATEDON" || item.SubItems[1].Text.ToUpper() == "STATUS")
                        {
                            continue;
                        }
                        sbNewSection.Append("\t\t\t\t");
                        string strParameter = @"SQLServer.AddInParameter(dbCommand, ""[AT]"", " + GetDataType(item.SubItems[2].Text) + ", " + txtEntityName.Text.Replace("Entity", "") + "." + item.SubItems[1].Text + ");\n";
                        strParameter = strParameter.Replace("[AT]","@"+ item.SubItems[1].Text);
                        sbNewSection.Append(strParameter);
                    }
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@By"", DbType.Guid, Current.Userid);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@On"", DbType.DateTime, DateTime.Now);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("using (DbConnection con = SQLServer.CreateConnection())\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("IResult = SQLServer.ExecuteScalar(dbCommand).ToString();\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("catch (Exception ex)\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("return IResult;\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\n");

                    //update
                    sbNewSection.Append("public string Update" + txtEntityName.Text.Replace("Entity", "") + "(" + txtEntityName.Text + " " + txtEntityName.Text.Replace("Entity", "") + ")\n");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"string IResult = ""SME"";");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"try");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append(DbComment);
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@Mode"", DbType.String, eMode.UPD);");
                    
                    sbNewSection.Append("\n");
                    for (int i = 0; i <= lstMainList.Items.Count - 1; i++)
                    {
                        ListViewItem item = lstvColumns.Items[i];
                        if (item.SubItems[1].Text.ToUpper() == "CREATEDBY" || item.SubItems[1].Text.ToUpper() == "UPDATEDBY" || item.SubItems[1].Text.ToUpper() == "CREATEDON" || item.SubItems[1].Text.ToUpper() == "UPDATEDON" || item.SubItems[1].Text.ToUpper() == "STATUS")
                        {
                            continue;
                        }
                        sbNewSection.Append("\t\t\t\t");
                        string strParameter = @"SQLServer.AddInParameter(dbCommand, ""[AT]"", " + GetDataType(item.SubItems[2].Text) + ", " + txtEntityName.Text.Replace("Entity", "") + "." + item.SubItems[1].Text + ");\n";
                        strParameter = strParameter.Replace("[AT]", "@" + item.SubItems[1].Text);
                        sbNewSection.Append(strParameter);
                    }
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@By"", DbType.Guid, Current.Userid);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@On"", DbType.DateTime, DateTime.Now);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("using (DbConnection con = SQLServer.CreateConnection())\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("IResult = SQLServer.ExecuteScalar(dbCommand).ToString();\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("catch (Exception ex)\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("return IResult;\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\n");


                    //Delete
                    sbNewSection.Append("public string Delete" + txtEntityName.Text.Replace("Entity", "") + "(Guid " + txtEntityName.Text.Replace("Entity", "") + "Id)\n");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"string IResult = ""SME"";");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"try");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append(DbComment);
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@Mode"", DbType.String, eMode.DEL);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, @" + txtEntityName.Text.Replace("Entity", "") + "Id, DbType.Guid, " + txtEntityName.Text.Replace("Entity", "") + "Id);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("using (DbConnection con = SQLServer.CreateConnection())\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("IResult = SQLServer.ExecuteScalar(dbCommand).ToString();\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("catch (Exception ex)\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("return IResult;\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\n");

                    //GetOne
                    sbNewSection.Append("public Entity" + txtEntityName.Text + " Get" + txtEntityName.Text + "(Guid " + txtEntityName.Text + "Id)");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append(@"Entity"+ txtEntityName.Text+" " + txtEntityName.Text + " = new Entity" + txtEntityName.Text + "();\n");
                    sbNewSection.Append(@"try");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append(@"using (DbCommand dbCommand = SQLServer.GetStoredProcCommand(""[dbo].[IDU_ChurchWorker]""))");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@Mode"", DbType.String, eMode.ONE);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append(@"SQLServer.AddInParameter(dbCommand, ""@ChangeId"", DbType.Guid, "+ txtEntityName.Text + "Id);");
                    sbNewSection.Append("\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("using (DbConnection con = SQLServer.CreateConnection())\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("using (IDataReader OReader = SQLServer.ExecuteReader(dbCommand))\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("if (OReader == null)\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("return ChurchWorker;\n");
                    sbNewSection.Append("\t\t\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("while (OReader.Read())\n");
                    sbNewSection.Append("\t\t\t\t\t");
                    sbNewSection.Append("{\n");
                    for (int i = 0; i <= lstMainList.Items.Count - 1; i++)
                    {
                        ListViewItem item = lstvColumns.Items[i];
                        if (item.SubItems[1].Text.ToUpper() == "CREATEDBY" || item.SubItems[1].Text.ToUpper() == "UPDATEDBY" || item.SubItems[1].Text.ToUpper() == "CREATEDON" || item.SubItems[1].Text.ToUpper() == "UPDATEDON" || item.SubItems[1].Text.ToUpper() == "STATUS")
                        {
                            continue;
                        }
                        sbNewSection.Append("\t\t\t\t");
                        string strParameter = @""+ txtEntityName.Text + "."+ item.SubItems[1].Text + " = (Guid)OReader["+ item.SubItems[1].Text + "]\n";
                        sbNewSection.Append(strParameter);
                    }
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("catch (Exception ex)\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("{\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\t\t");
                    sbNewSection.Append("return IResult;\n");
                    sbNewSection.Append("\t");
                    sbNewSection.Append("}\n");
                    sbNewSection.Append("\n");

                    sbNewSection.Append("---------------DataAccess End--------------\n");
                    sbNewSection.Append("\n\n\n");
                    ///DataAccess Generation End

                }



                rchResult.Text = sbNewSection.ToString();
                
            }
            else
            {
                MessageBox.Show("Please Give ProcedureName");
            }
        }
        public string GetDataType(string DataType)
        {
            string Type = "";
            switch (DataType.ToUpper())
            {
                case "UNIQUEIDENTIFIER":
                    Type = "DbType.Guid";
                    break;
                case "INT":
                    Type = "DbType.Int32";
                    break;
                case "NVARCHAR":
                    Type = "DbType.String";
                    break;
                case "DATETIME":
                    Type = "DbType.DateTime";
                    break;
                case "BIT":
                    Type = "DbType.Boolean";
                    break;
                default:
                    break;
            }
            return Type;
        }
        public string GetIsNullCondition(string value)
        {
            StringBuilder sbIsNull = new StringBuilder();
            if (value == "YES")
            {
                sbIsNull.Append("=NULL,\n");
            }
            else
            {
                sbIsNull.Append(",\n");
            }
            return sbIsNull.ToString();
        }

        private void chkGenerate_CheckedChanged(object sender, EventArgs e)
        {
            if(chkGenerate.Checked)
            {
                txtEntityName.Enabled = true;
            }
        }
    }
}

